#ifndef CARGO_MANAGER_H
#define CARGO_MANAGER_H
#ifndef SHAPE_H
#include "./Shape.h"
#endif
#ifndef COLOR_H
#include "./Color.h"
#endif

#ifndef PAINTSYSTEM_H
#include "../PaintSystem/paint_system.h"
#endif
#include <unordered_map>
class Cargo_Manager
{
protected:
    std::unordered_map<std::string, ShapeDefine *> shape_define_map;
    std::unordered_map<char,ColorDefine *> color_define_map;
    PaintSystem * paint_system = null;
    void setupManager();
public:
    Cargo_Manager(PaintSystem * paint_system);
    ~Cargo_Manager();

    /// @brief 根据定义生成图形货物 不要在外界调用
    /// @param define 图形货物的定义
    /// @return 如果为空则生成nullptr,否则根据define是否曾经生成，生成shape
    ShapeCargo *generateShapeCargoWithShapeDefine(ShapeDefine *define);
    void paintShapeCargo(int x, int y,gate::GateDirection g, ShapeCargo *shape);
    void paintColorCargo(int x, int y,gate::GateDirection g, ColorCargo *color);
    ShapeCargo *generateShapeCargoWithHashId(std::string hash_id);
    ColorCargo *generateColorCargoWithHashId(char hash_id);
    // 混色，裁剪，染色，旋转，堆叠

    /// @brief 裁剪
    /// @return 裁剪后的货物 size = 2
    std::pair<ShapeCargo *,ShapeCargo *> cropShape(ShapeCargo *shape);

    /// @brief 染色
    ShapeCargo *colorShapeWithColor(ShapeCargo *shape, ColorCargo *color);

    /// @brief 混色
    ColorCargo *mixColors(ColorCargo *color1, ColorCargo *color2);

    /// @brief 转弯
    Cargo *turnDirection(Cargo* cargo,bool is_clockwise);

    /// @brief 堆叠
    ShapeCargo *stack(ShapeCargo * shape1, ShapeCargo *shape2);
};

#endif
